<?php

include_once 'Answer_Patterns.php';
include_once 'Mount_DOM_tree.php';

class Refactoring_Tag_Meta extends Answer_Patterns {

   public function start($domDocument) {
      $result = "";
      $mount_tree = new Mount_DOM_tree();

      $search = $domDocument->getElementsByTagName('meta');

      foreach ($search as $f) {
         if ( $f->getAttribute('http-equiv') == "Content-Type" && !empty($f->getAttribute('content')) ) {
            $answer = (ereg("^(.*)utf-8$", strtolower($f->getAttribute('content'))) ? ' charset="UTF-8"' : ' charset="Codificação do texto"');
            $result .= parent::elementAnswerPatterns("&LT;$f->nodeName&GT;", $f->getLineNo(), $answer, "Adicione o atributo ", "remover os atributos <em>http-equiv</em> e/ou <em>content</em>");
            $result .= parent::tableAnswer($mount_tree->structHTML($f, 1, 0), $mount_tree->structHTMLElementRefactory($f, 1, 0, "$f->nodeName", 0, $answer));
         }
      }

      if (!empty($result)) {
         $result = parent::titleAnswerPatterns("Resumir a tag &LT;meta&GT;") . $result;
      }
      return $result;
   }

}

?>